package com.herui.ota.controller;

import com.herui.ota.config.ControllerNames;
import com.herui.ota.service.iml.LightUserAccountServiceIml;
import com.mlnx.common.annotations.NeedLogin;
import com.mlnx.common.entity.Response;
import com.mlnx.common.entity.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.spring.base.BaseController;
import org.shan.spring.base.annotations.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserCache;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by amanda.shan on 2020/6/18.
 */
@Api(value = ControllerNames.UserAccountName + "接口", tags = {ControllerNames.UserAccountName + "接口"})
@SysLog(title = ControllerNames.UserAccountName)
@RestController
@RequestMapping("/account")
public class UserAccountController extends BaseController {

    @Autowired
    private LightUserAccountServiceIml userAccountService;

    @NeedLogin
    @ApiOperation(value = "获取各种类型用户信息", notes = "")
    @GetMapping("/info")
    public ResponseData<UserCache> getAllUserInfo() {

        return result(userAccountService.getUserCache(true));
    }

    @ApiOperation(value = "获取手机验证码", notes = "")
    @GetMapping("/phoneCode")
    public Response getPhoneCode(String phone) {

        userAccountService.getPhoneCode(phone);
        return result();
    }

    @ApiOperation(value = "解除账户锁定", notes = "")
    @GetMapping("/unLock")
    public Response unLock(Integer userId) {

        userAccountService.unLock(userId);
        return result();
    }
}
